#include "stdafx.h"
#include <afxdllx.h>
#include <MyControls/Language.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

static AFX_EXTENSION_MODULE MyControlsDLL = { NULL, NULL };
static My::DLLLanguage theLanguage;

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
	UNREFERENCED_PARAMETER(lpReserved);

	if (dwReason == DLL_PROCESS_ATTACH)
	{
		if (!AfxInitExtensionModule(MyControlsDLL, hInstance))
			return 0;
		new CDynLinkLibrary(MyControlsDLL);
		theLanguage.Init(hInstance);

		char buf[MAX_PATH];
		GetModuleFileName(hInstance, buf, MAX_PATH);
		int n = AddFontResource(buf);
		TRACE1("%d fonts added.\n", n);
	}
	else if (dwReason == DLL_PROCESS_DETACH)
	{
		AfxTermExtensionModule(MyControlsDLL);

		char buf[MAX_PATH];
		GetModuleFileName(hInstance, buf, MAX_PATH);
		RemoveFontResource(buf);
	}
	return 1;   // ok
}
